﻿using M_Process.API.Appliction.Command;
using M_Process.Domain;
using M_Process.Repository.ProcessImpl;
using M_Process.Repository.ProcessInterface;
using MediatR;

namespace M_Process.API.Appliction.CommandHandlers
{
    public class ProcessProceduresBackfillGoongyiCommandHandler : IRequestHandler<ProcessProceduresBackfillGoongyiCommand, ProductionProcess>
    {
        //工艺
        protected readonly IProcessRouteRepository processRoute;
        protected readonly IProcessProceduresRepository processProcedures;
        //工序
        protected readonly IProductionProcessRepository productionProcessRepositor;

        public ProcessProceduresBackfillGoongyiCommandHandler(IProcessRouteRepository processRoute, IProcessProceduresRepository processProcedures, IProductionProcessRepository productionProcessRepositor)
        {
            this.processRoute = processRoute;
            this.processProcedures = processProcedures;
            this.productionProcessRepositor = productionProcessRepositor;
        }

        public async Task<ProductionProcess> Handle(ProcessProceduresBackfillGoongyiCommand request, CancellationToken cancellationToken)
        {
           var id=request.ProcessRouteId;
            var res = await processProcedures.GetModelsAsync(id);
            var prod = await productionProcessRepositor.GetModelsAsync(res.ProductionProcessesId);
            return prod;
        }
    }
}
